#include <iostream>
#include <numeric>
#include <vector>
#include <unordered_set>

using namespace std;

static int proper_divisor_sum(int num) {
    if (num < 2)
        return 0;

    vector<int> v;
    for (int i = 1; i < num; ++i) {
        if (num % i == 0)
            v.push_back(i);
    }

    return accumulate(v.begin(), v.end(), 0);
}

int main() {
    constexpr int limit = 28123;
    vector<int> abundant;
    for (int i = 0; i <= limit; ++i) {
        if (proper_divisor_sum(i) > i) {
            abundant.push_back(i);
            // cout << i << endl;
        }
    }
    unordered_set<int> abundant_sum;
    for (int i = 0; i < abundant.size(); ++i) {
        for (int j = i; j < abundant.size(); ++j) {
            int t = abundant[i] + abundant[j];
            if (t <= limit)
                abundant_sum.insert(t);
        }
    }
    int64_t sum = (1 + limit) * limit / 2;
    cout << sum - accumulate(abundant_sum.begin(), abundant_sum.end(), 0)<< endl; // 4179871
}
